package org.mianshi.metaapp;

/**
 * 思路  其实就是求 log2 N   之后再向上取整
 *
 *
 */
public class 返回某个数最小的2的N次方 {
    public static void main(String[] args) {
        System.out.println(return2(5));
        System.out.println(return2n(5));
    }


    public static double return2n(Integer param){
        if (param<=1){
            return 1;
        }
        double ceil = Math.ceil(Math.log(param) / Math.log(2));
        return Math.pow(2,ceil);
    }


    public static double return2(Integer param){
        int a = 0;
        double res = 0;
        while (true){
            if (res>=param){
                return res;
            }else {
                res = Math.pow(2,a);
                a++;
            }
        }
    }



}
